package cn.edu.ujn.booksshop.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.edu.ujn.booksshop.dao.Review;
import cn.edu.ujn.booksshop.dao.ReviewMapper;
import cn.edu.ujn.util.Page;
@Service
@Transactional
public class ReviewServiceImpl implements IReviewService {

	@Autowired
	private ReviewMapper reviewDao;
	@Override
	public List<Review> selectByUserId(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Page<Review> selectAll(Integer page,Integer rows) {
		// TODO Auto-generated method stub
		List<Review> list = this.reviewDao.selectAll((page-1)*rows,rows);
		Page<Review> pages = new Page<Review>();
		pages.setPage(page);
		pages.setRows(list);
		pages.setSize(rows);
		Integer count = this.reviewDao.selectCount();
		pages.setTotal(count);
		return pages;
	}

	@Override
	public int insert(Review row) {
		// TODO Auto-generated method stub
		int insert = this.reviewDao.insert(row);
		return insert;
	}

	@Override
	public int deleteByPrimaryKey(Integer reviewid) {
		// TODO Auto-generated method stub
		int delete = this.reviewDao.deleteByPrimaryKey(reviewid);
		return delete;
	}

	@Override
	public int updateByPrimaryKeySelective(Review row) {
		// TODO Auto-generated method stub
		int selective = this.reviewDao.updateByPrimaryKeySelective(row);
		return selective;
	}

	@Override
	public Review getReviewById(Integer id) {
		// TODO Auto-generated method stub
		Review review = this.reviewDao.selectByPrimaryKey(id);
		return review;
	}

}
